<template>
	<div id="head">
		<x-header :left-options="{showBack: false}" class="header" title="slot:overwrite-title">
			<a slot="left" href="#/Category"><i class="tp-icon icon_home_search"></i></a>
			<div class="header-overwrite-title" slot="overwrite-title">
				<button-tab>
					<button-tab-item :key="index" @on-item-click="tabChange(index,item.path)" v-for="(item,index) in list" :selected="item.name === $route.name">
						{{item.text}}
					</button-tab-item>
				</button-tab>
			</div>
			<a slot="right" @click="getShopInfo"><i class="tp-icon icon-photo"></i></a>
		</x-header>
		<confirm v-model="show4" :show-cancel-button="false" title="对不起您尚未认证店铺" @on-confirm="onConfirm">
			<p style="text-align:center;">请前往认证</p>
		</confirm>
	</div>
</template>

<script>
	import { XHeader, ButtonTab, ButtonTabItem, Tab, TabItem, Confirm } from 'vux'
	export default { //变量
		data() {
			return {
				shop_state: '',
				show4: false,
				list: [{
						name: 'Home',
						path: '/Home',
						text: '推荐'
					},
					{
						name: 'Attention',
						path: '/Attention',
						text: '关注'
					},
				]
			}
		},
		components: {
			XHeader,
			ButtonTab,
			ButtonTabItem,
			Tab,
			TabItem,
			Confirm
		},
		methods: {
			onConfirm: function() {
				location.href = '#/Certification'
			},
			tabChange: function(index, url) {
				this.$router.push(url);
			},
			//获取店铺信息 判断是否认证过  state=0 为认证
			getShopInfo: function() {
				if(JSON.parse(window.sessionStorage.getItem("member")).shop_id > 0 || JSON.parse(window.sessionStorage.getItem("shop")).shop_id > 0) {
					this.$http({
						method: 'GET',
						url: '/los/api/member/shop_info.json',
						data: ''
					}).then((result) => {
						if(result.data.code == 1) {
							this.shop_state = result.data.data.shop_state;
							if(this.shop_state == 0) {
								this.show4 = !this.show4;
							} else {
								location.href = '#/Upload'
							}
						}

					}).catch((err) => {
						console.log(err);
					})
				} else {
					this.show4 = !this.show4;
				}
			},
		}
	}
</script>

<style scoped>
	.header {
		background-color: #fff !important;
	}
</style>
